const {
  read
} = require("fs");

const app = getApp()
const wait = duration => new Promise(resolve => setTimeout(resolve, duration))
Page({
  data: {
    underindex: 0,
    marqueeProps: {
      loop: true,
    },
    newHomebanner: [],
    newnav: [],
    hotProduct: [],
    underProduct: [],
    home_yiyuan: '',
    fourpic: '',
    goodbooks: '',
    under_fl: [{
      name: '基础办公',
      childen: "热门优选"
    }, {
      name: '商务便捷',
      childen: "为你推荐"
    }, {
      name: '图形设计',
      childen: "生活必备"
    }, {
      name: '编程开发',
      childen: "猜你喜欢"
    }, ],
    homeoptions: '',
    lbshop: [],
    homedatesnew: [],
    idi: '',
    lifeFollow: my.canIUse('life-follow'),
    rgba: 0,
    lbtop: 'https://static.jxqyfw.com/upload/2023/01/c037dd4a-4927-4891-8418-deb2aca3ebc0.png',
    lbback: 'https://static.jxqyfw.com/upload/2023/01/2738a5ed-bd56-4201-a800-65c91e5d9370.png',
    homedates: '',
    sqyy: '',
    rzsjdates: '',
    bannertwo: '',

    fourpic: '',
    bkzq: '',
    hwtj: '',
    videodate: '',
    intervals: "",
    tabbar: {},
    advertising: false,
    times: 5, //倒计时 秒

    recordsapple: '',
    modal_status: false, //  广告弹窗隐藏
    modal_status2: false,
    nav: [],
    gd: false,
    recordsanzhuo: '',
    banners: [{
        imgUrl: "/image/otherImg/banner_02.png",
        show: true,
        url: '/pages/order/ordervip/ordervip'
      },
      {
        imgUrl: "/image/otherImg/banner_01.png",
        show: true,
        url: '/pages/active/newSale/newSale'
      }
    ],
    log: 0,
    autoplays: true,
    interval: 3000,
    fristback: 'linear-gradient(#0D1E17,#285740)',
    lineback: 'linear-gradient(#285740,#fff)',
    colorshow: '#0D1E17',
    qhid: '2',
    valuesj: '店铺',
    showsjiao: false,
    search: {
      filterWord: '',
      pageSize: 10,
      pageNo: 1,
      tid: null,
    },
    typeIndex: 0,
    city: '全国',
    systemInfo: {},

    banner: '',
    active: [

    ],
    zoneImg: [

    ],

    img: 'https://static.yirenzuji.com/upload/20210701/ff59c1007a5f482795967b0da951d53e.png',
    unders: [

    ],
    video: {
      src: "https://static.zxs.jxqyfw.com/video/yxb.mp4",
      showAllControls: false,
      showPlayButton: false,
      showCenterButton: true,
      showFullScreenButton: false,
      isLooping: true,
      muteWhenPlaying: true,
      initTime: 0,
      objectFit: "fill",
      autoPlay: false,
      directionWhenFullScreen: 0,
      mobilenetHintType: 3,
    },
    icon: [{
        title: '国行正品',
        icon: 'icon-zhengpin'
      },
      {
        title: '芝麻信用',
        icon: 'icon-zhima1'
      },
      {
        title: '隐私安全',
        icon: 'icon-anquan'
      },
      {
        title: '0元免押',
        icon: 'icon-jine'
      },
    ]
  },

  handletouchstart(e) {
    console.log("@@0", e)
  },
  shop_timer() {
    var that = this;
    setTimeout(function () {
      that.setData({
        modal_status: true, //  新店开业图片隐藏
        modal_status2: true, // 遮罩层隐藏
      });
      app.globalData.modal_shop = 2
    }, 7000);
  },
  close_btn() {

    this.setData({
      modal_status: true, //  新店开业图片隐藏
      modal_status2: true, // 遮罩层隐藏
    });
  },
  join_qun() {
    const path = 'alipays://platformapi/startapp?appId=68687451&url=%2Fwww%2Fbc-join.html%3Foid%3D2023082915213000010204%26businessId%3D2023082915213000010204%26businessType%3D18%26source%3DTINYAPP';
    my.ap.navigateToAlipayPage({
      path
    });
  },
  under_eve(e) {

    console.log("112233++++1", e)

    let homdedata = this.data.homedates
    console.log("112233++++2", homdedata);
    this.setData({
      underindex: e.target.dataset.index,
      homedatesnew: homdedata.zone[e.target.dataset.index].newProduct
    })
    console.log("112233++++3", this.data.homedatesnew)

    //  else if (e.target.dataset.index == '1') {
    //   let homdedata = this.data.homedates
    //   this.setData({
    //     underindex: e.target.dataset.index,
    //     homedatesnew: homdedata.rzsj.plist.slice(6, 12)
    //   })
    // } else if (e.target.dataset.index == '2') {
    //   let homdedata = this.data.homedates
    //   this.setData({
    //     underindex: e.target.dataset.index,
    //     homedatesnew: homdedata.rzsj.plist.slice(12, 18)
    //   })
    // } else if (e.target.dataset.index == '3') {
    //   let homdedata = this.data.homedates
    //   this.setData({
    //     underindex: e.target.dataset.index,
    //     homedatesnew: homdedata.rzsj.plist.slice(18, 24)
    //   })
    // }
  },
  jmp: function () {
    this.setData({
      advertising: false
    });
    my.showTabBar({
      animation: true //动画效果
    });
    clearInterval(this.data.intervals)
    this.onReady()
  }, //跳过广告

  onLoad(optiosn) {
    app._init_(this)

    let appQuery = my.getLaunchOptionsSync();


    let appQuerys = my.getEnterOptionsSync();


    if (appQuery.query) {

      optiosn = appQuery.query

    }
    if (appQuerys.query) {
      optiosn = appQuerys.query
    }
    if (optiosn.flowState && optiosn.promotionAccount) {
      app.globalData.flowState = optiosn.flowState
      app.globalData.promotionAccount = optiosn.promotionAccount
      app.globalData.clickid = optiosn.clickid
      let datas = {}
      datas.promotionAccount = optiosn.promotionAccount
      datas.flowState = optiosn.flowState
      datas.clickid = optiosn.clickid
      my.setStorage({
        key: 'promotionAccount',
        data: datas,
      })

    }



    let homesdate = my.getStorageSync({
      key: 'homedata'
    }).data;
    console.log("12233445345345", homesdate)
    if (homesdate) {


      this.setData({
        newHomebanner: homesdate.newHomebanner,
        // newnav: homesdate.newnav,
        hotProduct: homesdate.hotProduct,
        underProduct: homesdate.underProduct,
        // fourpic: homesdate.fourpic,
        // goodbooks: homesdate.goodbooks,
        homedates: homesdate.homedates,
        homedatesnew: homesdate.homedatesnew,
      })


      setTimeout(() => {
        this.getHome(0)
      }, 3000);

    } else {
      this.getHome(0)
    }


    // my.hideTabBar()
    // this.changeEvents(0)
    // this.x = setTimeout(() => {
    //   this.setData({
    //     times: this.data.times - 1
    //   })
    //   if (this.data.times == 0) {
    //     this.jmp()
    //   }
    // }, 3000) //每秒执行一次

    // setTimeout(function () {
    //   my.showTabBar({
    //     animation: true
    //   })
    // }, 1000);
    // this.setData({
    //   //给声明的变量interval赋值，每1000毫秒执行一次   广告
    //   intervals: setInterval(() => {
    //     this.setTimer()
    //   }, 1000)
    // })


    if (app.globalData.modal_shop == 1) {
      this.shop_timer() // 调用定时器方法
    } else {
      this.setData({
        modal_status: true, //  广告弹窗隐藏
        modal_status2: true, // 广告弹窗隐藏
      });
    }

    //my.hideTabBar()
    // app.editTabbar();
    console.log("shoyeonload", optiosn)
    if (optiosn.puid) {
      //分销分享参数接收
      // this.setData({
      //   homeoptions: optiosn.puid    })
      my.setStorage({
        key: 'puid',
        data: optiosn.puid,
      })
    } else if (optiosn.vip) {

      my.reLaunch({
        url: '/pages/active/numSale/numSale'
      });
    }



  },

  setTimer() {
    this.setData({
      times: this.data.times - 1
    })

    if (this.data.times == 0) {
      this.jmp()
    }

  },
  // 小程序的钩子函数
  onPageScroll: (function () {

    let timer = null;
    return function (e) {
      if (e.scrollTop >= 0) {
        let opacity = e.scrollTop / 200
        opacity = opacity > 1 ? 1 : opacity
        this.setData({
          rgba: opacity
        })
      }

      // 监听页面的滚动开始和结束
      clearTimeout(timer);
      this.scrollIng = true;
      timer = setTimeout(() => {
        console.log("滚动结束");
        this.scrollIng = false;
      }, 500);
      this.scrollTop = e.scrollTop;
    };

  })(),
  live_page() {
    my.navigateTo({
      url: '/pages/user/live/live'
    });
  },
  showmot() {
    my.alert({
      title: '公告',
      content: ' 友情提示：租租乐未和任何中介机构进行合作，请勿信包过，垫付等任何承诺。为了您的资金安全，请勿线下付款，如遇此类问题，请联系租租乐客服。',
      buttonText: '确定',
      success: () => {

      }
    });
  },
  config() {

    var that = this;
    app.other.config()
      .then(res => {
        console.info("响应码:", res.data);
        for (const key in res.data.data) {
          // console.info("响应码:", key);
          if (res.data.data.hasOwnProperty(key)) {
            const element = res.data.data[key];
            if (element.name == "shops_enter") {
              that.setData({
                idi: element.content
              })
            }
          }
        }



      })




  },
  scroll(e) {
    console.log("----", e)
    var datas = my.getStorageSync({
      key: 'unrderdata'
    });
    let eventsGoods = datas.data.remen;

    // var recordsanzhuo = my.getStorageSync({ key: 'recordsanzhuo' }).data;

    // this.Homeonmoney(1)

    this.setData({
      prudects: eventsGoods,
      // unders: [
      //   { title: '热门', titles: '精品手机' },
      //   { title: '推荐', titles: '为你推荐' },
      //   { title: '配件', titles: '生活必备' },
      //   { title: '安卓', titles: '猜你喜欢' },
      // ],
    })


  },
  onReady() {

    my.createIntersectionObserver().relativeToViewport({
      top: 0,
      bottom: 0
    }).observe('.icon_list', (res) => {
      if (res.boundingClientRect.bottom < 0) {
        console.log(res, '+66666666666666666------------------------');


      }




      console.log(res, '+66666666666666666------------------------');
    });

    my.createIntersectionObserver().relativeToViewport({
      top: 0,
      bottom: 0
    }).observe('.icon_list', (res) => {

      this.setData({
        gd: false
      })


      console.log(res, '22222222222222222222222222222------------------------');

    });

    my.createIntersectionObserver().relativeToViewport({
      top: 0,
      bottom: 0
    }).observe('.gdjt', (res) => {
      if (res.boundingClientRect.top > 0) {
        this.setData({
          gd: true
        })
      }



      console.log(res, '101111111111111111111111111111111111------------------------');

    });
    // my.createIntersectionObserver().relativeToViewport({ top: 0, bottom: 0 }).observe('.product-price', (res) => {

    //   this.setData({
    //     gd: false
    //   })


    //   console.log(res, '22222222222222222222222222222------------------------');

    // });
  },

  show() {
    this.setData({
      modal_status: false,
      modal_status2: false,
    })
  },
  Homeonmoney() {
    let that = this;
    let e = {}
    e.page = 'false',
      e.firstMoney = '100',
      // e.type = '2'
      e.state = 0



    app.other.products(e)
      .then(json => {
        // console.log("一元首月", json)
        json.data.forEach((json) => {
          //   console.log("一元首月1", json)
          json.params = JSON.parse(json.params)
          json.slideshows = JSON.parse(json.slideshows)
          json.msg = `${json.tit}`
          json.image = json.slideshows[0]
          this.setData({
            data: json
          });
          //   console.log("一元首月2", json)
          let params = {
            tit: ""
          }
          params.tit = json.params
          let splitPrice = ''
          if (params.tit.length > '1') {
            splitPrice = (params.tit[0].term_list[0].specifications[0].money / 100 - 1) / 11
          } else {
            splitPrice = (params.tit[0].term_list[0].specifications[0].money / 100 - 1) / 11
          }


          //   console.log("一元首月3", splitPrice)
          json.sprices = splitPrice.toFixed(2)
        })
        //  console.log("==============一元首月4============", json.data.data)
        var list = json.data;
        var newArr = []; //新数组
        for (let i = 0; i < list.length; i += 3) { //拆分三个
          newArr.push(list.slice(i, i + 3))
        }
        console.log("==========================", newArr)

        this.setData({
          records: newArr
        })

      })
  },
  onHide() {
    console.log("yincang", )
    this.setData({
      autoplays: false
    })
  },

  changeEvent(e) {
    // console.log("lunbo ", e.detail.current)
    if (e.detail.current == '0') {
      this.setData({
        log: 0,
        colorshow: '#0D1E17',
        fristback: 'linear-gradient(#0D1E17,#285740)',
        lineback: 'linear-gradient(#285740,#fff)',
      })
    } else if (e.detail.current == '1') {
      this.setData({
        log: 1,
        colorshow: '#3F21B6',
        fristback: 'linear-gradient(#3F21B6,#414CDA)',
        lineback: 'linear-gradient(#414CDA,#fff)',
      })
    } else if (e.detail.current == '2') {
      this.setData({
        log: 2,
        colorshow: '#141E52',
        fristback: 'linear-gradient(#141E52,#192B87)',
        lineback: 'linear-gradient(#192B87,#fff)',

      })
    } else if (e.detail.current == '3') {
      this.setData({
        log: 3,
        colorshow: '#2E8BF2',
        fristback: 'linear-gradient(#2E8BF2,#3F96F8)',
        lineback: 'linear-gradient(#3F96F8,#fff)',

      })
    } else if (e.detail.current == '4') {
      this.setData({
        log: 4,
        colorshow: '#1d1309',
        fristback: 'linear-gradient(#1d1309,#5e462d)',
        lineback: 'linear-gradient(#5e462d,#fff)',

      })
    }

  },
  changeEvents(e) {

    // if (this.data.homedates.threebox){
    // let datab = this.data.homedates.threebox.plist

    // if (e.detail.current == '0') {
    //   let lbshop = datab.slice(0,3)
    //   console.log("1", lbshop)
    //   this.setData({
    //     lbtop:'https://static.jxqyfw.com/upload/2023/01/c037dd4a-4927-4891-8418-deb2aca3ebc0.png',
    //     lbback: "https://static.jxqyfw.com/upload/2023/03/546a069d-beee-4ae6-b986-1b4768731856.png",
    //     lbshop: lbshop
    //   })
    // } else if (e.detail.current == '1') {
    //   let lbshop = datab.slice(3, 6)
    //   console.log("2", lbshop)
    //   this.setData({
    //     lbtop: 'https://static.jxqyfw.com/upload/2023/01/d4804cab-4a9b-4d63-9950-6d94c1fdde4b.png',
    //     lbback: "https://static.jxqyfw.com/upload/2023/03/2503e924-671f-477c-9826-c31176cd86e4.png",
    //     lbshop: lbshop

    //   })
    // } else if (e.detail.current == '2') {
    //   let lbshop = datab.slice(6, 10)
    //   console.log("3", lbshop)
    //   this.setData({
    //     lbtop: 'https://static.jxqyfw.com/upload/2023/01/7d15f559-d7bd-42fb-8b75-6e19d153bb24.png',
    //     lbback: "https://static.jxqyfw.com/upload/2023/03/2fb9ebaf-5285-4020-90fb-8f5e503c841a.png",
    //     lbshop: lbshop
    //   })
    // } 
    // }
    // if(e == '0'){
    //   app.other.home()
    //     .then(res => {

    //       this.setData({
    //         lbshop: res.data.threebox ? res.data.threebox.plist.slice(0, 3) : ''
    //       })

    //     })
    // }
  },
  scrollTo() {
    my.pageScrollTo({
      scrollTop: 0,
      duration: 300,
    });
  },
  showsjiaoz() {
    if (this.data.showsjiao) {
      this.setData({
        showsjiao: false
      })
    } else {
      this.setData({
        showsjiao: true
      })
    }
  },
  search_fun(e) {
    // console.log("222",e)
    this.setData({
      showsjiao: false
    })
    if (e.currentTarget.dataset.id == '1') {
      this.setData({
        valuesj: '店铺',
        qhid: '1'
      })
    } else {
      this.setData({
        valuesj: '商品',
        qhid: '2'
      })
    }
  },
  onShow() {
    // my.hideTabBar()

    var datasss = my.getSystemInfoSync()
    // my.hideShareMenu()
    console.log("datasss", datasss)
    // this.Homeonmoney()
    console.log("app.globalData.userlocation", app.globalData.userlocation)
    // if (this.data.city == ''  ){
    //   this.getLocation()
    // }
    my.getOpenUserInfo({
      success: (res) => {
        console.log("getOpenUserInfo=================>>>>>>", res);
      }
    })
    let nameid = my.getStorageSync({
      key: 'promotionAccount'
    }).data ? my.getStorageSync({
      key: 'promotionAccount'
    }).data.clickid : null
    this.setData({
      nameid: nameid,
      autoplays: true,
      scrollw: datasss.windowHeight
    })
    // this.config()

    // this.scroll()
    this.getSystemInfo();
    // this.Homeonmoneyapple();

  },
  getLocation() {
    let that = this
    my.getLocation({
      type: 1,
      success(res) {
        // console.log("=====================>>获取地理位置22222", res)
        ////console.log(res)
        that.setData({
          city: res.city
        })
        app.globalData.userlocation = `${res.province}-${res.city}-${res.district}`
      },
      fail(res) {
        console.log("=====================>>获取地理位置3333", res)
        let openLocation = res.error
        my.confirm({
          title: '温馨提示',
          content: '为了给你提供更优质的的位置 \n 服务，请先选择你的所在城市',
          confirmButtonText: '马上选择',
          cancelButtonText: '暂不需要',
          success: (result) => {
            console.log("=====================>>result", result)
            if (result.confirm) {
              if (openLocation == '11') {
                my.showToast({
                  content: '请打开手机定位权限！'
                })

              } else if (openLocation == '2002') {
                that.openSetting()
                that.setData({
                  city: '全国'
                })

              } else {
                that.getLocation()
              }

            } else {
              // that.chooseCity()
              that.setData({
                city: '全国'
              })
              app.globalData.userlocation = app.globalData.userlocation || '用户拒绝访问当前地址'
              // 用户拒绝
            }
          },
        });
      },
    })
  },
  openSetting() {
    // .js
    my.openSetting({
      success: (res) => {

        if (!res.authSetting.location) {

          this.getLocation()

        }


      },
      complete: (res) => {

      },
    })
  },
  choose_fl(e) {
    var datas = my.getStorageSync({
      key: 'unrderdata'
    });
    console.log("eeeee", datas)
    this.setData({
      typeIndex: e.currentTarget.dataset.index
    })
    if (e.currentTarget.dataset.index == '0') {
      let eventsGoods = datas.data.remen
      ////console.log("11111", eventsGoods)
      this.setData({
        prudects: eventsGoods
      })
    } else if (e.currentTarget.dataset.index == '1') {
      let eventsGoods = datas.data.tuijian
      ////console.log("11111", eventsGoods)
      this.setData({
        prudects: eventsGoods
      })
    } else if (e.currentTarget.dataset.index == '2') {
      let eventsGoods = datas.data.peijian
      ////console.log("11111", eventsGoods)
      this.setData({
        prudects: eventsGoods
      })
    } else if (e.currentTarget.dataset.index == '3') {
      let eventsGoods = datas.data.anzhuo
      ////console.log("11111", eventsGoods)
      this.setData({
        prudects: eventsGoods
      })
    }
    // this.getHome(e.currentTarget.dataset.index)
  },
  second(e) {
    ////console.log("3333",e)

    my.navigateTo({
      url: '../../product/second/second?data=' + e.currentTarget.dataset.id
    });
  },
  getSystemInfo() {
    my.getSystemInfo({
      success: (res) => {
        console.log("444", res)
        this.setData({
          systemInfo: res
        })
      }
    })
  },
  onConfirm(e) {
    this.btn(e.detail.value)


  },
  btn(w) {
    my.getOpenUserInfo({
      fail: (res) => {
        my.alert({
          content: "请先登录后使用"
        });
      },
      success: (res) => {
        console.log("getOpenUserInfo=================>>>>>>", res);
        this.login(res.response)
          .then((res) => {
            console.log("11", res)
            this.submit(w)
          })
      }
    });
  },
  login(response, func) {
    //console.log("======================login登录=========================")
    return new Promise((resolve, reject) => {
      const that = this;
      func = func ? func : () => {};
      response = response ? response : "";
      if (!response) {
        return
      }
      my.getAuthCode({
        scopes: 'auth_base',
        success: (res) => {
          const appIdRes = my.getAppIdSync();

          let deviceInfor = my.getSystemInfoSync()
          console.log("getAuthCode===========>>>", res)
          let sbInfor = {}
          sbInfor.currentBattery = deviceInfor.currentBattery
          sbInfor.brand = deviceInfor.brand
          sbInfor.system = deviceInfor.system
          sbInfor.language = deviceInfor.language
          sbInfor.model = deviceInfor.model
          sbInfor.version = deviceInfor.version
          sbInfor.fontSizeSetting = deviceInfor.fontSizeSetting
          sbInfor.platform = deviceInfor.platform
          sbInfor.storage = deviceInfor.storage
          sbInfor.app = deviceInfor.app
          console.log("112233++++", deviceInfor)
          let data = {
            devInfo: JSON.stringify(sbInfor),
            authCode: res.authCode,
            appletId: appIdRes.appId ? appIdRes.appId : '2021004124696308',
            param: response,
            promotionAccount: my.getStorageSync({
              key: 'promotionAccount'
            }).data ? my.getStorageSync({
              key: 'promotionAccount'
            }).data.promotionAccount : null,
            flowState: my.getStorageSync({
              key: 'promotionAccount'
            }).data ? my.getStorageSync({
              key: 'promotionAccount'
            }).data.flowState : null
          }
          app.user.login(data)
            .then(json => {
              console.log("===============>>>登陆", json)
              my.hideLoading()
              if (json.code != 200) {
                my.alert({
                  content: json.msg
                });
                return;
              }
              // json.data.user.id = 57692
              if (json.data) {
                my.setStorage({
                  key: 'user',
                  data: json.data.user,
                })
                my.setStorage({
                  key: 'token',
                  data: json.data.token,
                })
                resolve(json)
              }
            })
        },
        fail: () => {
          reject()
        }
      });

    })

  },
  submit(e) {

    console.log("6666+", e)
    let search = {
      tit: e
    }
    app.other.shopslist(search)
      .then(res => {
        if (res.data.data.length > 0) {
          let data = {}
          data.id = res.data.data[0].id
          data.image = res.data.data[0].image
          data.tit = res.data.data[0].tit
          my.navigateTo({
            url: '/pages/product/shops/shops?param=' + JSON.stringify(data),
            success: () => {

            },
            fail: () => {

            },
            complete: () => {

            }
          });
        } else {
          my.showToast({
            type: 'exception ',
            content: '暂未有该商家！',
            duration: 1000,
          });
        }

      })

  },
  // 转价格
  dataPromise(list) {
    return new Promise((relose, reject) => {
      console.log("ewe.", list)
      list.forEach((item) => {



        this.getminPrice(item.params)
          .then(res => {
            item.pricess = res
          })
      })
      relose(list)
    })
  },

  getminPrice(params) {
    return new Promise((resole, reject) => {
      let prices = []
      for (let i = 0; i < params.length; i++) {
        for (let t = 0; t < params[i].term_list.length; t++) {
          for (let s = 0; s < params[i].term_list[t].specifications.length; s++) {
            let price = (params[i].term_list[t].specifications[s].money / params[i].term_list[t].value / 100).toFixed(2)
            prices.push(price)
          }
        }
      }
      let minprice = Math.min.apply(null, prices);
      console.log("1112233", minprice)
      resole(minprice)
    })
  },

  getHome(e) {

    app.other.home()
      .then(res => {
        console.log("1111999", JSON.parse(res.data.slideShows))
        // eventsGoods 为你推荐
        // bigType 活动页
        // hot 精选页面
        // slideShows 首页数据
        let {
          data
        } = JSON.parse(res.data.slideShows)
        if (data.nav) {
          // var newArr = []; //新数组分类
          // for (let i = 0; i < res.data.nav.plist.length; i += 8) { //拆分三个
          //   newArr.push(res.data.nav.plist.slice(i, i + 8))
          // }
          // res.data.nav.plist = newArr
          this.setData({
            newHomebanner: data.banner,
            // newnav: res.data.nav.plist,
            hotProduct: data.newA.newProduct,
            underProduct: data.zone,
            // fourpic: res.data.fourpic,
            // goodbooks: res.data.goodbooks,

          })
          let datashome = {}
          datashome.newHomebanner = data.banner,
            // datashome.newnav = res.data.nav.plist,
            datashome.hotProduct = data.newA.newProduct,
            datashome.underProduct = data.zone,
            // datashome.fourpic = res.data.fourpic,
            // datashome.goodbooks = res.data.goodbooks,
            datashome.homedates = data,
            datashome.homedatesnew = data.zone[0].newProduct,
            my.setStorageSync({
              key: 'homedata',
              data: datashome,
            })
          setTimeout(() => {
            this.nextdate(data)
          }, 2000);

        }

        console.log("++++", res.data)


        console.log("11223344", this.data.homedates)
      })
  },
  nextdate(e) {
    console.log("11122yihuan ", e)
    this.setData({

      homedates: e,
      homedatesnew: e.zone[0].newProduct,

    })

  },
  // 跳转
  navigateTosss(e) {

    console.log("iiiiiiiiii", e)
    if (e.target.dataset.url != '') {
      app.navigateTo(e)
    }
  },
  navigateTo(e) {
    console.log("iiiiiiiiii", e)
    if (e.target.dataset.url != '') {
      if (e.target.dataset.url == '/pages/order/ipon/ipon') {
        this.jmp()
      }
      app.navigateTo(e)
    }
  },

  navigateTos(e) {


    //console.log("111111111111111111111111111",e)
    app.globalData.categorynum = e.currentTarget.dataset.param
    my.switchTab({
      url: e.currentTarget.dataset.url
    });

  },
  chooseCity() {
    let that = this;
    my.chooseCity({
      showLocatedCity: true,
      showHotCities: true,
      success: (res) => {
        ////console.log("222", res)
        that.setData({
          city: res.city
        })
        // my.alert({
        //   title: 'chooseCity response: ' + JSON.stringify(res),
        // });
      },
    });
  },
  onReachBottom() {
    console.log("#@##########################")


  },
  // 跳转外部链接
  navigateToAlipayPage() {
    my.ap.navigateToAlipayPage({
      // 例如跳转到支付宝出行页面
      // path: 'alipays://platformapi/startapp?appId=2021001152620480&page=pages/signH5/index&'
      path: ' https://render.alipay.com/p/c/?appId=2021001152620480&page=pages/signH5/index&query=signUrl%3Dhttps%253A%252F%252Ftsign.cloud.alipay.com%252Fweb%252FhandMultifileSign%253Ftimestamp%253D1645777908337%2526flowId%253D359e1cd25b484d08acd17895ece6f09d%2526accountId%253DDAWRSKNY121%2526sign%253D6c718f21cc601cbc77d7215d8910512558f944156d16171e7befb5575833aa02',
      success: () => {
        my.alert({
          content: '成功'
        });
      },
      fail: (error) => {
        my.alert({
          content: '失败：' + JSON.stringify(error)
        });
      }
    })
  },
});